//
//  HomeCycyleView.m
//  Project2
//
//  Created by hundredsandc on 2017/11/6.
//  Copyright © 2017年 hundredsandc. All rights reserved.
//

#import "HomeCycyleView.h"

@interface HomeCycyleView  ()
@property (nonatomic,strong)UILabel *timeLabel;
@property (nonatomic,strong) UILabel* titleLabel;
@property (nonatomic,strong) UILabel* subTimeLabel;
@property (nonatomic,strong) UILabel* teamOneName;
@property (nonatomic,strong) UILabel* teamOneScore;
@property (nonatomic,strong) UILabel* teamTwoName;
@property (nonatomic,strong) UILabel* teamTwoScore;
@property (nonatomic,strong) UILabel* mid;
@property (nonatomic,strong) UILabel* teamOneSub;
@property (nonatomic,strong) UILabel* teamTwoSub;
@end
@implementation HomeCycyleView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        _timeLabel = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0x66, 0x66, 0x66) withTextFont:FONT(12) withTextAlignment:NSTextAlignmentLeft withTextContent:nil];
        [self addSubview:_timeLabel];
        
        _titleLabel = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0xb5, 0x29, 0xff) withTextFont:FONT(12) withTextAlignment:NSTextAlignmentRight withTextContent:nil];
        [self addSubview:_titleLabel];
        
        _subTimeLabel = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0x66, 0x66, 0x66) withTextFont:FONT(12) withTextAlignment:NSTextAlignmentLeft withTextContent:nil];
        [self addSubview:_subTimeLabel];
        
        _mid =[UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0xff, 0x27, 0x41) withTextFont:FONT(24) withTextAlignment:NSTextAlignmentCenter withTextContent:@"-"];
        [self addSubview:_mid];
        
        _teamOneScore = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0xff, 0x27, 0x41) withTextFont:FONT(24) withTextAlignment:NSTextAlignmentRight withTextContent:nil];
        [self addSubview:_teamOneScore];
        
        _teamOneName = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0x66, 0x66, 0x66) withTextFont:FONT(15) withTextAlignment:NSTextAlignmentRight withTextContent:nil];
        [self addSubview:_teamOneName];
        
        _teamTwoScore = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0xff, 0x27, 0x41) withTextFont:FONT(24) withTextAlignment:NSTextAlignmentLeft withTextContent:nil];
        [self addSubview:_teamTwoScore];
        
        _teamTwoName = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0x66, 0x66, 0x66) withTextFont:FONT(15) withTextAlignment:NSTextAlignmentLeft withTextContent:nil];
        [self addSubview:_teamTwoName];
        
        _teamOneSub = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0x66, 0x66, 0x66) withTextFont:FONT(12) withTextAlignment:NSTextAlignmentRight withTextContent:nil];
        
        [self addSubview:_teamOneSub];
        _teamOneSub.hidden = YES;
        
        _teamTwoSub = [UIManage createUILabelFrame:CGRectZero withBackColor:nil withTextColor:RGBCOLOR(0x66, 0x66, 0x66) withTextFont:FONT(12) withTextAlignment:NSTextAlignmentLeft withTextContent:nil];
        [self addSubview:_teamTwoSub];
        _teamTwoSub.hidden = YES;
        [self addConstraint];
        
    }
    return self;
}
-(void)customWithTiime:(NSString *)time title:(NSString *)title subTime:(NSString *)subTime TeamOneName:(NSString *)TeamOneName TeamOneScore:(NSString *)TeamOneScore TeamTwoName:(NSString *)TeamTwoName TeamTwoScore:(NSString *)TeamTwoScore subOne:(NSString *)subOne subTwo:(NSString *)subTwo{
    _timeLabel.text = time;
    _titleLabel.text = title;
    _subTimeLabel.text = subTime;
    _teamOneName.text = TeamOneName;
    _teamOneScore.text = TeamOneScore;
    _teamOneSub.text = subOne;
    
    _teamTwoName.text = TeamTwoName;
    _teamTwoScore.text = TeamTwoScore;
    _teamTwoSub.text = subTwo;
}
-(void)addConstraint{
    WS(ws);
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(ws).with.offset(15);
        make.top.equalTo(ws).with.offset(18);
        make.size.mas_equalTo(CGSizeMake(200, 12));
    }];
    
    
    [_mid mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(ws).with.offset(70);
        make.left.equalTo(ws).with.offset((SCREEN_WIDTH-10)/2);
        make.size.mas_equalTo(CGSizeMake(10, 24));
    }];
    
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_timeLabel.mas_bottom).with.offset(18);
        make.right.equalTo(_mid.mas_left).with.offset(-90);
        make.size.mas_equalTo(CGSizeMake(100, 12));
    }];
    
    [_subTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_timeLabel.mas_bottom).with.offset(18);
        make.left.equalTo(_titleLabel.mas_right).with.offset(15);
        make.size.mas_equalTo(CGSizeMake(100, 12));

    }];
    
    [_teamOneScore mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_mid.mas_top);
        make.right.equalTo(_mid.mas_left).with.offset(-6);
        make.size.mas_equalTo(CGSizeMake(50, 24));
    }];
    
    [_teamOneName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_mid.mas_top);
        make.right.equalTo(_teamOneScore.mas_left).with.offset(-25);
        make.size.mas_equalTo(CGSizeMake(100, 24));
    }];
    [_teamTwoScore mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_mid.mas_top);
        make.left.equalTo(_mid.mas_right).with.offset(6);
        make.size.mas_equalTo(CGSizeMake(50, 24));
    }];
    
    [_teamTwoName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_mid.mas_top);
        make.left.equalTo(_teamTwoScore.mas_right).with.offset(25);
        make.size.mas_equalTo(CGSizeMake(100, 24));
    }];
    
    [_teamOneSub mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_mid.mas_bottom).with.offset(10);
        make.right.equalTo(_mid.mas_left).with.offset(-44);
        make.size.mas_equalTo(CGSizeMake(150, 12));
    }];
    
    [_teamTwoSub mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_mid.mas_bottom).with.offset(10);
        make.left.equalTo(_mid.mas_right).with.offset(44);
        make.size.mas_equalTo(CGSizeMake(150, 12));
    }];
}
@end
